package com.leftheart.entity;


import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.leftheart.utils.DateUtils;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.util.Date;

@Data
@NoArgsConstructor
//@Entity
//@DynamicInsert
//@DynamicUpdate
public class Books implements Serializable {
    private int bookId;
    private String bookName;
    private String bookVersion;
    private String author;
    private String amount;
    private String remark;
//    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd hh:mm:ss")
//    @DateTimeFormat(pattern="yyyy-MM-dd hh:mm:ss")
    private String bookDate;

    public String getBookDate() {
        return bookDate;
    }

    public void setBookDate() {
        this.bookDate = DateUtils.jsonDate(new Date());
    }

    public Books(int bookId, String bookName, String bookVersion, String author, String amount, String remark, String bookDate) throws JsonProcessingException {
        Date date = new Date();
        this.bookId = bookId;
        this.bookName = bookName;
        this.bookVersion = bookVersion;
        this.author = author;
        this.amount = amount;
        this.remark = remark;
        this.bookDate = DateUtils.jsonDate(date);
    }
}
